package edu.its.dreamteam.web.util;

import java.util.List;

import org.apache.tapestry.ValueEncoder;

import edu.its.dreamteam.daf.beans.Formation;

public class FormationValueEncoder implements ValueEncoder<Formation> {
	private List<Formation> formationList;
	public FormationValueEncoder(List<Formation> formationList){
		this.formationList = formationList;
	}
	public String toClient(Formation formation) {
		return formation.getFormation();
	}

	public Formation toValue(String value) {
		for(Formation formation : formationList){
			if(formation.getFormation().equals(value)){
				return formation;
			}
		}
		return null;
	}

}
